package com.zen.lon.open.remote.support;

import com.zen.lon.open.proxy.ProxyAgentMetaDataReader;
import com.zen.lon.open.remote.metadata.RemoteClientMetadata;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * RemoteClient元数据读取器
 *
 * @author ZonLen since on 2021/7/8 下午11:37
 */
public class RemoteClientMetaDataReader implements ProxyAgentMetaDataReader {

  private static final Map<Class<?>, RemoteClientMetadata> REMOTE_CLIENT_METADATA_CACHE = new ConcurrentHashMap<>();

  public static RemoteClientMetadata readProxyClass(
      Class<?> remoteApiClass) {
    return REMOTE_CLIENT_METADATA_CACHE.get(remoteApiClass);
  }

  @Override
  public void parseProxyClass(Class<?> proxyClass) {
      REMOTE_CLIENT_METADATA_CACHE
          .putIfAbsent(proxyClass, new RemoteClientMetadata(proxyClass));
  }


}
